package com.wunong.smart.commission.client.rpc;

import com.wunong.smart.commission.client.dto.CommissionDTO;
import com.wunong.smart.commission.client.query.CommissionQueryDTO;
import com.wunong.smart.commission.client.service.CommissionReadService;
import com.wunong.smart.domain.platform.rpc.ResultHandler;
import lombok.Setter;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * 代办服务RpcClient
 *
 * @author create by zealot.zt
 */
public class CommissionReadRpcClient {

    @Setter
    @Resource
    private CommissionReadService commissionReadService;

    public CommissionDTO getById(Long id) {
        final String format = "commission#getById, id:%s";

        return ResultHandler.invoke(() -> commissionReadService.getById(id), format, id);
    }

    public List<CommissionDTO> queryByIds(Collection<Long> ids) {
        final String format = "commission#queryByIds, ids:%s";

        return ResultHandler.invoke(() -> commissionReadService.queryByIds(ids), format, ids);
    }

    public CommissionDTO getById(Long userId, Long id) {
        final String format = "commission#getById, userId:%s, id:%s";

        return ResultHandler.invoke(() -> commissionReadService.getById(userId, id), format, userId, id);
    }

    public List<CommissionDTO> queryByBiz(String bizId, Integer bizType, Integer commissionType) {
        final String format = "commission#queryByBiz, bizId:%s, bizType:%s, commissionType:%s";
        return ResultHandler.invoke(() -> commissionReadService.queryByBiz(bizId, bizType, commissionType),
                format, bizId, bizType);
    }

    public List<CommissionDTO> query(CommissionQueryDTO query) {
        final String format = "commission#query, query:%s";

        return ResultHandler.invoke(() -> commissionReadService.query(query),
                format, query);
    }

}
